#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
#
# Distributed under terms of the MIT license.

"""

"""

from math import fabs as abs


PRECISION = 0.00000000001

def squeeze(num, nth, guess):
    # 逼近猜测的过程
    guess_one_side   = guess ** (nth-1)
    guess_other_side = float(num) / guess_one_side

    if abs(guess - guess_other_side) <= PRECISION:
        return guess

    new_guess = (guess * (nth-1) + guess_other_side) / float(nth)
    print(new_guess, guess_other_side)
    return squeeze(num, nth, new_guess)


def root(num, nth, guess=1):
    return squeeze(num, nth, guess)


def main():
    print("start main")
    print(root(27, 3, 2))

if __name__ == "__main__":
    main()
